#!/bin/bash
Downurl='https://gitee.com/RuoliCloud/YUMsh/raw/master'
uptime=$(curl -sSL https://gitee.com/RuoliCloud/YUMsh/raw/master/yumupdate.txt)
system=$(cut /etc/redhat-release -b 22)
function Finish() {
      yum clean all
      yum makecache
      clear
      echo "Finish"
      echo "If you want to run again"
      echo "The original Yum file has been renamed to CentOS-Base.repo.bak"
      echo "You can enter:yumcdsh"
}
#快捷启动
rm -rf $0
wget $Downurl/$0 -O /bin/yumcdsh
chmod -R 777 /bin/yumcdsh
#备份原YUM
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
#删除多余Repo源
rm -rf /etc/yum.repos.d/*.repo

clear
case $1 in
-A)
      wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-vault-${system}.5.2111.repo
      if [ "$system" == '8' ]; then
            wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-archive-8.repo
      else
            wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-${system}.repo
      fi
      Finish
      ;;
-W)
      wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS${system}-Base-163.repo
      Finish
      ;;
-I)
      wget -O /etc/yum.repos.d/CentOS-Base.repo http://github.itzmx.com/1265578519/mirrors/master/CentOS/CentOS${system}-Base-itzmx.repo
      Finish
      ;;
-R)
      rm -rf /etc/yum.repos.d/CentOS-Base.repo
      mv /etc/yumrepos.d/CentOS-Base.repo.bak /etc/yum.repos.d/CentOS-Base.repo
      Finish
      ;;
*)
      mv /etc/yum.repos.d/CentOS-Base.repo.bak /etc/yum.repos.d/CentOS-Base.repo
      echo "None"
      echo "If you want to run again"
      echo "You can enter:yumcdsh + (option)"
      echo "Aliyun          -A"
      echo "Wangyi          -W"
      echo "Itzmx           -I"
      echo "Retrun          -R"
      exit
      ;;
esac
